#!/usr/bin/env python3.10
# -*- encoding: utf-8 -*-
'''
@File    :   main.py
@Time    :   2023/05/04 15:56:32
@Author  :   windstarry 
@Version :   1.0
'''
# here put the import lib

import os

import uvicorn

from app.config import settings


def run_server(host: str = settings.server_host, port: int = settings.server_port):
    # 获取日志配置文件的路径
    project_env = 'prod' if os.getenv('PROJECT_ENV') == 'prod' else 'dev'
    log_config_path = str(settings.base_dir / 'app' / 'config' / f'logging.{project_env}.json')
    uvicorn.run(
            app='app.main:app',
            host=host,
            port=port,
            reload=settings.debug,
            reload_dirs=["app"],
            log_config=log_config_path
    )

if __name__ == "__main__":
    run_server()